/**
 * 
 */
package com.firebird.oms.user;

import java.io.Serializable;
import java.security.Principal;
import java.util.Date;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * @author qiuxj
 * @date 2009-11-21
 * 
 */
public class UserDetails implements Principal, Serializable {

	private static final long serialVersionUID = 2638021500470235320L;
	private Integer loginid;
	private Integer staffId;
	private String logincode;
	private String password;
	private String username;
	private Integer state;
	private Integer loginnum;
	private Integer loginlevel;
	private Date lastChgPwdTime;
	private Date lastLoginTime;
	private Integer upStaffId;

	public UserDetails() {
	}

	public UserDetails(String logincode, String password, String username,
			Integer state, Integer loginnum, Integer loginlevel,
			Date lastChgPwdTime, Date lastLoginTime) {
		this.logincode = logincode;
		this.password = password;
		this.username = username;
		this.state = state;
		this.loginnum = loginnum;
		this.loginlevel = loginlevel;
		this.lastChgPwdTime = lastChgPwdTime;
		this.lastLoginTime = lastLoginTime;
	}

	public Integer getLoginid() {
		return loginid;
	}

	public void setLoginid(Integer loginid) {
		this.loginid = loginid;
	}

	public void setLogincode(String logincode) {
		this.logincode = logincode;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public Integer getState() {
		return state;
	}

	public void setState(Integer state) {
		this.state = state;
	}

	public String getLogincode() {
		return this.logincode;
	}

	public String getPassword() {
		return this.password;
	}

	public String getUsername() {
		return this.username;
	}

	public Integer getLoginnum() {
		return this.loginnum;
	}

	public void setLoginnum(Integer loginnum) {
		this.loginnum = loginnum;
	}

	public Integer getLoginlevel() {
		return this.loginlevel;
	}

	public void setLoginlevel(Integer loginlevel) {
		this.loginlevel = loginlevel;
	}

	public Date getLastChgPwdTime() {
		return this.lastChgPwdTime;
	}

	public void setLastChgPwdTime(Date lastChgPwdTime) {
		this.lastChgPwdTime = lastChgPwdTime;
	}

	public String getName() {
		return this.logincode;
	}

	public Date getLastLoginTime() {
		return lastLoginTime;
	}

	public void setLastLoginTime(Date lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}

	public Integer getStaffId() {
		return staffId;
	}

	public void setStaffId(Integer staffId) {
		this.staffId = staffId;
	}

	public Integer getUpStaffId() {
		return upStaffId;
	}

	public void setUpStaffId(Integer upStaffId) {
		this.upStaffId = upStaffId;
	}

	public boolean equals(final Object other) {
		if (!(other instanceof UserDetails))
			return false;
		UserDetails castOther = (UserDetails) other;
		return new EqualsBuilder().append(loginid, castOther.loginid).append(
				staffId, castOther.staffId).append(logincode,
				castOther.logincode).append(password, castOther.password)
				.append(username, castOther.username).append(state,
						castOther.state).append(loginnum, castOther.loginnum)
				.append(loginlevel, castOther.loginlevel).append(
						lastChgPwdTime, castOther.lastChgPwdTime).append(
						lastLoginTime, castOther.lastLoginTime).append(
						upStaffId, castOther.upStaffId).isEquals();
	}

	public int hashCode() {
		return new HashCodeBuilder().append(loginid).append(staffId).append(
				logincode).append(password).append(username).append(state)
				.append(loginnum).append(loginlevel).append(lastChgPwdTime)
				.append(lastLoginTime).append(upStaffId).toHashCode();
	}

	public String toString() {
		return new ToStringBuilder(this).append("loginid", loginid).append(
				"staffId", staffId).append("logincode", logincode).append(
				"password", password).append("username", username).append(
				"state", state).append("loginnum", loginnum).append(
				"loginlevel", loginlevel).append("lastChgPwdTime",
				lastChgPwdTime).append("lastLoginTime", lastLoginTime).append(
				"upStaffId", upStaffId).toString();
	}

}
